package com.example.eschool.son_fragment_home;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListView;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.eschool.R;
import com.example.eschool.adapter.questionAdapter;

import java.util.ArrayList;
import java.util.List;


public class NewsFragment extends Fragment implements View.OnClickListener{
    View rootview;
    ListView listView;
    List<String> NewsList = new ArrayList<>();
    public NewsFragment() {

    }


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        listView = view.findViewById(R.id.news_item); // 从view中查找ListView

        for (int i = 0; i < 10; i++) {
            String question = "News " + i;
            NewsList.add(question);
        }
        questionAdapter adapter = new questionAdapter(getContext(), R.layout.question_item, NewsList);
        listView.setAdapter(adapter);

    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        if (rootview == null){
            rootview=inflater.inflate(R.layout.son_fragment_news, container, false);
        }

        return rootview;
    }

    @Override
    public void onClick(View v) {

    }


}